//
//  PeoplePhotoViewController.m
//  AILove
//
//  Created by 甘世清 on 2024/1/7.
//

#import "PeoplePhotoViewController.h"
#import "JieGuoView.h"
@interface PeoplePhotoViewController ()

@end

@implementation PeoplePhotoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)SQ_UIViewForSelfView{
    UIImageView * bgView = [[UIImageView alloc]init];
    [bgView sd_setImageWithURL:SQURLImage(self.seletedModel.url)];
    bgView.clipsToBounds = YES;
    bgView.contentMode = UIViewContentModeScaleAspectFill;
    [self.view addSubview:bgView];
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view);
    }];
    HeaderView * btn = [[HeaderView alloc]init];
    btn.image = @"按钮背景";
    btn.text = SQNSLocalString(@"设置为角色封面");
    btn.font = FONT_BOLD(16);
    [btn.btn addTarget:self action:@selector(SQ_buttonClick) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(self.view);
            make.height.mas_equalTo(50);
            make.bottom.equalTo(self.view.mas_bottom).offset(-FootHeight);
    }];
}
-(void)SQ_buttonClick{
    [YJProgressHUD SQ_showMsgWithoutView:@""];
    NSMutableDictionary * dic = [[NSMutableDictionary alloc]init];
    [dic setObject:self.seletedModel.userId forKey:@"photoId"];
    [HttpTool post:Url17 paramDic:dic successBlock:^(BaseModel * _Nonnull httpModel) {
        self.model.cover = self.seletedModel.url;
        [self SQ_goumaichenggong];
    } andFailBloc:^(BaseModel * _Nonnull httpModel, NSError * _Nullable error) {
        [YJProgressHUD showMsgWithoutView:httpModel.message];
    }];
}

-(void)SQ_goumaichenggong{
    JieGuoView * vc = [[JieGuoView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDETH, SCREEN_HEIGHT)];
    vc.oneLabel.text = SQNSLocalString(@"设置成功");
    vc.towLabel.text = SQNSLocalString(@"角色封面以替换,请返回查看");
    LSTPopView * pop = [LSTPopView initWithCustomView:vc
                                           parentView:nil
                                             popStyle:LSTPopStyleFade dismissStyle:LSTDismissStyleFade];
    pop.hemStyle = LSTHemStyleCenter;
    pop.isStack = YES;
    [pop pop];
    LSTPopViewWK(pop)
    WS(weakSelf);
    [vc setJGBlock:^{
        [wk_pop dismiss];
    }];
}

@end
